package config

import (
	"gitee.com/wujianqiang/golibs/keycloak"
	"gitee.com/wujianqiang/golibs/pkg/factory"
	"gitee.com/wujianqiang/golibs/pkg/jwt"
	"gitee.com/wujianqiang/golibs/pkg/logging"
	"gitee.com/wujianqiang/golibs/pkg/spice"

	"github.com/redis/go-redis/v9"
	"gorm.io/gorm"
)

var Appconfig *AppConfig

type Server struct {
	//Host string `yaml:"host"`
	Port int `yaml:"port"`
}

type AppConfig struct {
	Server      Server                `yaml:"server"`
	Mysql       factory.MySqlInfo     `yaml:"mysql"`
	Redis       factory.RedisInfo     `yaml:"redis"`
	Log         logging.LogSettings   `yaml:"log"`
	Debug       bool                  `yaml:"debug"`
	Keycloak    keycloak.KeyCLoakInfo `yaml:"keycloak"`
	Jwt         jwt.JwtConfig         `yaml:"jwt"`
	SpiceConfig spice.SpiceConfig     `yaml:"spice"`
	DB          *gorm.DB
	RDS         *redis.Client
	SPDB        *spice.SpiceSrv
}

func SetAppConfig(a *AppConfig) {
	Appconfig = a
	logging.SetLogger(&a.Log, a.Debug)
}
